package ar.edu.utn.frgp.labtec.actions;

import java.util.HashSet;
import java.util.Set;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ar.edu.utn.frgp.labtec.entities.TipoPermisoEnum;

import com.opensymphony.xwork2.ActionSupport;

public abstract class BaseAction extends ActionSupport{
	
	private static final long serialVersionUID = 1L;
	private String[] contexto = new String[] {"hibernate-spring.xml", 
			"daos.xml", "services.xml"};
	
	private ApplicationContext ctx;
	
	protected Set<TipoPermisoEnum> permisos;
	
	public ApplicationContext getContext(){
		if(ctx == null){
			ctx = new ClassPathXmlApplicationContext(contexto);
		}
		return ctx;
		
	}
	
	public BaseAction(){
		permisos = new HashSet<TipoPermisoEnum>();
		permisos.add(TipoPermisoEnum.A);
	}

	public Set<TipoPermisoEnum> getPermisos() {
		return permisos;
	}

	public void setPermisos(Set<TipoPermisoEnum> permisos) {
		this.permisos = permisos;
	}
	
	
}
